﻿@using Microsoft.AspNetCore.Hosting
@using Microsoft.AspNetCore.Mvc.ViewEngines
@inject IWebHostEnvironment Environment
@inject ICompositeViewEngine Engine
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"] - @Environment.ApplicationName</title>

    <environment include="Development">
        <link rel="stylesheet" href="~/Identity/lib/bootstrap/dist/css/bootstrap.css" />
        <link rel="stylesheet" href="~/Identity/css/site.css" />
    </environment>
    <environment exclude="Development">
        <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
              integrity="sha256-PI8n5gCcz9cQqQXm3PEtDuPG8qx9oFsFctPg0S5zb8g=" crossorigin="anonymous"
              asp-fallback-href="~/Identity/lib/bootstrap/dist/css/bootstrap.min.css"
              asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
        <link rel="stylesheet" href="~/Identity/css/site.css" asp-append-version="true" />
    </environment>
</head>
<body>
    <header>
        <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
            <div class="container">
                <a class="navbar-brand" href="~/">@Environment.ApplicationName</a>
                <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
                        aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
                    @{
                        var result = Engine.FindView(ViewContext, "_LoginPartial", isMainPage: false);
                    }
                    @if (result.Success)
                    {
                        await Html.RenderPartialAsync("_LoginPartial");
                    }
                    else
                    {
                        throw new InvalidOperationException("The default Identity UI layout requires a partial view '_LoginPartial' " +
                            "usually located at '/Pages/_LoginPartial' or at '/Views/Shared/_LoginPartial' to work. Based on your configuration " +
                            $"we have looked at it in the following locations: {System.Environment.NewLine}{string.Join(System.Environment.NewLine, result.SearchedLocations)}.");
                    }
                </div>
            </div>
        </nav>
    </header>

    <div class="container">
        <partial name="_CookieConsentPartial" optional />
        <main role="main" class="pb-1">
            @RenderBody()
        </main>
    </div>
    <footer class="footer border-top pl-3 text-muted">
        <div class="container">
        &copy; @DateTime.Now.Year - @Environment.ApplicationName
            @{
                var foundPrivacy = Url.Page("/Privacy", new { area = "" });
            }
            @if (foundPrivacy != null)
            {
                @:-
                <a asp-area="" asp-page="/Privacy">Privacy</a>
            }
        </div>
    </footer>

    <environment include="Development">
        <script src="~/Identity/lib/jquery/dist/jquery.js"></script>
        <script src="~/Identity/lib/bootstrap/dist/js/bootstrap.bundle.js"></script>
        <script src="~/Identity/js/site.js" asp-append-version="true"></script>
    </environment>
    <environment exclude="Development">
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"
                asp-fallback-src="~/Identity/lib/jquery/dist/jquery.min.js"
                asp-fallback-test="window.jQuery"
                crossorigin="anonymous"
                integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=">
        </script>
        <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" 
                asp-fallback-src="~/Identity/lib/bootstrap/dist/js/bootstrap.bundle.min.js"
                asp-fallback-test="window.jQuery && window.jQuery.fn && window.jQuery.fn.modal"
                crossorigin="anonymous"
                integrity="sha256-CDOy6cOibCWEdsRiZuaHf8dSGGJRYuBGC+mjoJimHGw=">
        </script>
        <script src="~/Identity/js/site.js" asp-append-version="true"></script>
    </environment>

    @await RenderSectionAsync("Scripts", required: false)
</body>
</html>
